var common = require('../../utils/common.js');
var Base = require('../base.js');

var MCase = function({
  page,
  scope,
  cmpt
}) {
  Base.apply(this, arguments);
  this.init();
}

common.extend(MCase, Base);

Object.assign(MCase.prototype, {
  init() {
    var _self = this;
    var cmpt = this.curCmpt;

    wx.getSystemInfo({
      success: function(res) {
        var winWidth = res.windowWidth;
        var style = cmpt['content']['oStyle'];
        var marginLeft = parseFloat(style.marginLeft || 0);
        var gap = 2;
        var panelWid = winWidth - marginLeft * 2;
        var smWid = (panelWid - gap) / 2;
        var smHei = smWid * (263 / 373);
        var bigWid = (panelWid - gap) / 2;
        var bigHei = smHei * 2 + gap;

        _self.setData({
          panelWid,
          smWid,
          smHei,
          bigWid,
          bigHei,
          gap
        })
      }
    });
  },
});

MCase.props = {
  name: 'mCase'
};

module.exports = MCase;